package com.minggo.charmword.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;

import com.minggo.charmword.R;
import com.minggo.charmword.activity.AroundMapActivity;
import com.minggo.charmword.activity.UseHistoryActivity;
import com.minggo.charmword.activity.WordStoreActivity;


/**
 * ”我的“页面
 * @author minggo
 * @time 2014-10-1下午11:47:59
 */
public class FragmentMine extends BaseFragment implements OnClickListener {

	private Activity activity;
	private View mainView;

	private View newWordV;
	private View rememberV;
	private View historyV;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		this.activity = activity;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		mainView = inflater.inflate(R.layout.fragment_mine, null);
		newWordV = mainView.findViewById(R.id.lo_new);
		rememberV = mainView.findViewById(R.id.lo_remember);
		historyV = mainView.findViewById(R.id.lo_history);

		newWordV.setOnClickListener(this);
		rememberV.setOnClickListener(this);
		historyV.setOnClickListener(this);

		return super.onCreateView(inflater, container, savedInstanceState);
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		setContentView(mainView);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.lo_new:
			
			Intent intent0 = new Intent(activity, WordStoreActivity.class);
			intent0.putExtra("title", "生词本");
			intent0.putExtra("wordType", WordStoreActivity.NEW_WORD);
			activity.startActivity(intent0);
			 
			break;
		case R.id.lo_remember:
			Intent intent1 = new Intent(activity, WordStoreActivity.class);
			intent1.putExtra("wordType", WordStoreActivity.REMEMBER_WORD);
			intent1.putExtra("title", "已掌握单词");
			activity.startActivity(intent1);
			break;
		case R.id.lo_history:
			Intent intent2 = new Intent(activity, UseHistoryActivity.class);
			activity.startActivity(intent2);
			break;
		default:
			break;
		}
	}

	@Override
	public void onDetach() {
		super.onDetach();
		activity = null;
	}

	@Override
	protected void showData() {
		setContentShown(false);
		newWordV.postDelayed(new Runnable() {

			@Override
			public void run() {
				setContentShown(true);

			}
		}, 300);
	}
}
